<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActiveSupport::OrderedHash</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Class</span> 
            ActiveSupport::OrderedHash 
            
                <span class="parent">&lt; 
                    
                    <a href="../Hash.html">Hash</a>
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../../files/activesupport/lib/active_support/ordered_hash_rb.html">activesupport/lib/active_support/ordered_hash.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  
    <div class="description">
      
<p><code>ActiveSupport::OrderedHash</code> implements a hash that preserves
insertion order.</p>

<pre class="ruby"><span class="ruby-identifier">oh</span> = <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">OrderedHash</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">oh</span>[:<span class="ruby-identifier">a</span>] = <span class="ruby-value">1</span>
<span class="ruby-identifier">oh</span>[:<span class="ruby-identifier">b</span>] = <span class="ruby-value">2</span>
<span class="ruby-identifier">oh</span>.<span class="ruby-identifier">keys</span> <span class="ruby-comment"># =&gt; [:a, :b], this order is guaranteed</span>
</pre>

<p>Also, maps the <code>omap</code> feature for YAML files (See <a
href="http://yaml.org/type/omap.html">yaml.org/type/omap.html</a>) to
support ordered items when loading from yaml.</p>

<p><code>ActiveSupport::OrderedHash</code> is namespaced to prevent conflicts
with other implementations.</p>

    </div>
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>E</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="OrderedHash.html#method-i-encode_with">encode_with</a>,
              </li>
            
              
              <li>
                <a href="OrderedHash.html#method-i-extractable_options-3F">extractable_options?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>N</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="OrderedHash.html#method-i-nested_under_indifferent_access">nested_under_indifferent_access</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>T</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="OrderedHash.html#method-i-to_yaml_type">to_yaml_type</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-encode_with">
            
              <b>encode_with</b>(coder)
            
            <a href="OrderedHash.html#method-i-encode_with" name="method-i-encode_with" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-encode_with_source')" id="l_method-i-encode_with_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/b1dfcc968baa58d9a182ec7e129c901de0445971/activesupport/lib/active_support/ordered_hash.rb#L27" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-encode_with_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/ordered_hash.rb, line 27</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">encode_with</span>(<span class="ruby-identifier">coder</span>)
  <span class="ruby-identifier">coder</span>.<span class="ruby-identifier">represent_seq</span> <span class="ruby-string">'!omap'</span>, <span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> { <span class="ruby-identifier">k</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">v</span> } }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-extractable_options-3F">
            
              <b>extractable_options?</b>()
            
            <a href="OrderedHash.html#method-i-extractable_options-3F" name="method-i-extractable_options-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns true to make sure that this hash is extractable via
<code>Array#extract_options!</code></p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-extractable_options-3F_source')" id="l_method-i-extractable_options-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/b1dfcc968baa58d9a182ec7e129c901de0445971/activesupport/lib/active_support/ordered_hash.rb#L36" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-extractable_options-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/ordered_hash.rb, line 36</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">extractable_options?</span>
  <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-nested_under_indifferent_access">
            
              <b>nested_under_indifferent_access</b>()
            
            <a href="OrderedHash.html#method-i-nested_under_indifferent_access" name="method-i-nested_under_indifferent_access" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-nested_under_indifferent_access_source')" id="l_method-i-nested_under_indifferent_access_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/b1dfcc968baa58d9a182ec7e129c901de0445971/activesupport/lib/active_support/ordered_hash.rb#L31" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-nested_under_indifferent_access_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/ordered_hash.rb, line 31</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">nested_under_indifferent_access</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_yaml_type">
            
              <b>to_yaml_type</b>()
            
            <a href="OrderedHash.html#method-i-to_yaml_type" name="method-i-to_yaml_type" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-to_yaml_type_source')" id="l_method-i-to_yaml_type_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/b1dfcc968baa58d9a182ec7e129c901de0445971/activesupport/lib/active_support/ordered_hash.rb#L23" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-to_yaml_type_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/ordered_hash.rb, line 23</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">to_yaml_type</span>
  <span class="ruby-string">&quot;!tag:yaml.org,2002:omap&quot;</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    